/**
 * @author mixed
 */
(function(){
	addEventListener("orientationchange", function()
	{
	  iEvent._orientationEvent(window.orientation);
	}, true);
	
	window.iEvent = {
		_events:{
			shake:[]
		},
		_orientation:"",
		_timer:"",
		_orientationEvent : function(orientation){
			if(!this._timer){
				var owner = this;
				this._timer = setTimeout(function(){
					owner._timer = "";
					if(orientation!=owner._orientation){
						owner.onShake();
					}
				},1400);
			}
			this._changeMode(orientation);
		},
		_changeMode:function(orientation){
			this._orientation = orientation;
		},
		onShake:function(){
			var funcs = this._events["shake"];
			for(var i=0; i<funcs.length;i++){
				funcs[i]();
			}
		},
		addEventListener:function(type,func){
			this._events[type].push(func);
		}
	};
})();